<template>
  <div style="text-align: center">
    <el-dialog :title="title" :visible.sync="taskDatailsVisible" :append-to-body="true" @close="close()" style="text-align: center">
      <el-form :inline="true" :model="flowDetails" ref="flowDetails"  size="mini" label-width="150px">
        <el-form-item label="流程编号：">
          <el-input v-model="flowDetails.processId" placeholder="流程编号" clearable disabled="disabled"></el-input>
        </el-form-item>
        <el-form-item label="任务编号：">
          <el-input v-model="flowDetails.taskId" placeholder="任务编号" clearable disabled="disabled"></el-input>
        </el-form-item>
        <el-form-item label="申请姓名：">
          <el-input v-model="flowDetails.name" placeholder="申请姓名" clearable disabled="disabled"></el-input>
        </el-form-item>
        <el-form-item label="申请手机号：">
          <el-input v-model="flowDetails.mobliePhone" placeholder="申请手机号" clearable disabled="disabled"></el-input>
        </el-form-item>
        <el-form-item label="审批意见：" style="text-align: left">
          <el-radio v-model="opinion" label="1" :disabled="isViewAble">同意</el-radio>
          <el-radio v-model="opinion" label="0" :disabled="isViewAble">拒绝</el-radio>
        </el-form-item>
      </el-form>
      <div style="text-align: center">
        <el-button  type="primary" size="small" @click="submit()" v-if="isViewAble">提交</el-button>
        <el-button  type="warning" size="small" @click="close()">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
    import { commitTask } from '@/api/flow';
    export default {
        name: "taskDetails",
        props:{
            taskDatailsVisible:{default:()=>{ return false }},
            isViewAble:{default:()=>{ return null }},
            flowDetails:{default:()=>{ return {

                }}},
            tableData:{default:()=>{ return [{
                    userId:' ',
                    name: '客户',
                    code: 'backcus'
                }, {
                    userId:'  ',
                    name: '运营审核',
                    code: 'backyysh'
                }, {
                    userId:'    ',
                    name: '电调',
                    code: 'backdd'
                }, {
                    userId:'     ',
                    name: '审批',
                    code: 'backsp'
                }] }}
        },
        data () {
            return {
                visible: false,
                title:'任务审批',
                opinion:''
            }
        },
        methods:{
            close(){
                this.$emit('closeTaskDetails')
            },
            submit(){
                const variables={
                    "status":this.opinion
                }
                const param= {
                    'processId': this.flowDetails.processId,
                    'taskId': this.flowDetails.taskId,
                    'variables': variables,
                    'bizData':this.flowDetails
                }
                const requestData={
                    'data':param
                }
                commitTask(requestData).then((res)=>{
                    if(res.code=='0000'){
                        this.$message({message: '提交成功！', duration: 800});
                        this.close();
                    }else{
                        this.$message({message: res.message, duration: 800});
                    }
                }).catch((err)=>{

                })
            }
        }
    }
</script>

<style scoped>

</style>
